//
//  Dictionary.swift
//  CMKit
//
//  Created by travel on 2016/12/15.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import Foundation


extension Dictionary {
    /// 转化为 json 字符串
    ///
    /// - Parameter options:  json 序列化选项
    /// - Returns: 转化为 json 序列化串
    func toJsonString(options:JSONSerialization.WritingOptions = JSONSerialization.WritingOptions.init(rawValue: 0)) -> String? {
        do {
            let data = try JSONSerialization.data(withJSONObject: self, options: options)
            return String.init(data: data, encoding: String.Encoding.utf8)
        } catch {
            return nil
        }
    }
}
